package com.hopu.v1.pojo.system;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.hopu.v1.pojo.common.Save;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDate;

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("t_class")
public class Class implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 班级id
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 班级名称
     */
    @TableField("class_name")
    @Length(message = "班级名不低于6位", min = 6, groups = Save.class)
    @Pattern(regexp = "^[a-zA-Z][a-zA-Z0-9]{5,9}$",message = "格式不正确",groups = Save.class)
    @NotBlank(message = "班级名不能为空",groups = Save.class)
    private String className;

    /**
     * 班级描述
     */
    @TableField("class_description")
    private String classDescription;

    /**
     * 学科id
     */
    @TableField("subject_id")
    @NotNull(message = "学科不能为空",groups = Save.class)
    private Integer subjectId;

    /**
     * 班级状态
     */
    @TableField("class_status")
    private Integer classStatus;

    /**
     * 开班日期
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @TableField("start_date")
    private LocalDate startDate;

    /**
     * 班主任id
     */
    @TableField("teacher_id")
    @NotNull(message = "教师不能为空",groups = Save.class)
    private Integer teacherId;

    /**
     * 教员id
     */
    @TableField("staff_id")
    @NotNull(message = "教员不能为空",groups = Save.class)
    private Integer staffId;

    /**
     * 结业日期
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @TableField("end_date")
    private LocalDate endDate;
}
